package com.small.site.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author  xiaochi
 * @date    2021/11/21 13:38
 * @desc    自定义全局过滤器
 */
@Slf4j
@Component
public class GatewayGlobalFilter extends BaseGlobalFilter {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("全局过滤器执行了,上下文ctx={}",ctx);
        String path = exchange.getRequest().getURI().getPath();
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        //return Integer.MIN_VALUE;
        return Ordered.HIGHEST_PRECEDENCE;
    }
}
